package com.lu.pojo.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author luzhenfang
 * @date 2020 05 24
 * @description 线程池
 *  创建
 *  执行
 *  关闭
 */
public class ThreadPool {
    // 创建服务 创建线程池
    public static void main(String[] args) {
        ExecutorService service = Executors.newFixedThreadPool(10);
        // 执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        // 关闭连接
        service.shutdown();

    }

}
class MyThread implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"|"+i);

        }

    }
}
